class Solution {
public:
    vector<vector<int>> generate(int numRows) {
        vector<vector<int>> ret;
        vector<int> nums(1, 1);
        ret.emplace_back(nums);
        for (int n = 2; n <= numRows; n++) {
            nums.resize(n, 1);
            for (int i = n - 2; i > 0; i--) {
                nums[i] += nums[i - 1];
            }
            ret.emplace_back(nums);
        }
        return ret;
    }
};